15 openstreetmap
Uncomment the following line to install leafmap if needed.
In [1]:
# !pip install geopandas osmnx leafmap
In [2]:
import leafmap
Adds OSM data of place(s) by name or ID to the map.
In [3]:
m = leafmap.Map(google_map=None, toolbar_control=False, layers_control=True)
m.add_osm_from_geocode("New York City", layer_name='NYC')
m
Out[3]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [4]:
m = leafmap.Map(google_map=None, toolbar_control=False, layers_control=True)
m.add_osm_from_geocode("Knoxville, Tennessee", layer_name='Knoxville, TN')
m
Out[4]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Adds OSM entities within boundaries of geocodable place(s) to the map.
In [5]:
m = leafmap.Map(google_map=None, toolbar_control=False, layers_control=True)
place = "Bunker Hill, Los Angeles, California"
tags = {"building": True}
m.add_osm_from_place(place, tags, layer_name="Los Angeles, CA")
m
Out[5]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Shows OSM feature tags.
In [6]:
# leafmap.osm_tags_list()
/home/runner/.local/lib/python3.8/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above. and should_run_async(code)
Adds OSM entities within some distance N, S, E, W of address to the map.
In [7]:
m = leafmap.Map(google_map=None, toolbar_control=False, layers_control=True)
m.add_osm_from_address(
address="New York City",
tags={"amenity": "bar"},
dist=1500,
layer_name="NYC bars")
m
Out[7]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [8]:
m = leafmap.Map(google_map=None, toolbar_control=False, layers_control=True)
m.add_osm_from_address(
address="New York City",
tags={
"landuse": ["retail", "commercial"],
"building": True
},
dist=1000, layer_name="NYC buildings")
m
/home/runner/.local/lib/python3.8/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above. and should_run_async(code)
Out[8]:
Make this Notebook Trusted to load map: File -> Trust Notebook